// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   ReadRight.java

package com.oa.hr;

import com.oa.database.DataConn;
import com.oa.database.QueryData;
import com.oa.util.IndoString;
import java.io.PrintStream;
import java.sql.ResultSet;
import java.sql.SQLException;

public class ReadRight
{

    public ReadRight()
    {
    }

    public String read(String userid)
    {
        String sTemp = "0";
        String sYGZW = getYGZW(userid);
        String sYGBM = getYGBM(userid);
        String sYGZW_1 = "";
        String sYGBM_1 = "";
        boolean temp = true;
        try
        {
            DataConn dataConn = new DataConn();
            QueryData queryData = new QueryData(dataConn);
            String sTable = "OA_YG_JB";
            String sField = "YGID,JBXXID,YGXM,YGZW,YGBM";
            String sCondition = "1=1";
            queryData.setMultRecordSet(sTable, sField, sCondition);
            ResultSet rs;
            for(rs = queryData.getResultSet(); rs.next();)
            {
                sYGZW_1 = rs.getString("YGZW");
                sYGBM_1 = Integer.toString(rs.getInt("YGBM"));
                temp = compareDuty(sYGBM, sYGZW, sYGBM_1, sYGZW_1);
                if(temp)
                    sTemp = sTemp + "," + rs.getInt("JBXXID");
            }

            sTemp = sTemp + "," + getJBXXID(userid);
            rs.close();
            dataConn.close();
        }
        catch(SQLException sqlexception) { }
        return sTemp;
    }

    public String getJBXXID(String userid)
    {
        String sTemp = "0";
        try
        {
            DataConn dataConn = new DataConn();
            QueryData queryData = new QueryData(dataConn);
            String sTable = "OA_YG_JB";
            String sField = "JBXXID";
            String sCondition = "YGID=" + userid;
            queryData.setMultRecordSet(sTable, sField, sCondition);
            ResultSet rs = queryData.getResultSet();
            if(rs.next())
                sTemp = Integer.toString(rs.getInt("JBXXID"));
            rs.close();
            dataConn.close();
        }
        catch(SQLException sqlexception) { }
        return sTemp;
    }

    public String getYGZW(String userid)
    {
        String sTemp = "";
        try
        {
            DataConn dataConn = new DataConn();
            QueryData queryData = new QueryData(dataConn);
            String sTable = "OA_YGB";
            String sField = "ZWID";
            String sCondition = "YGID=" + userid;
            queryData.setMultRecordSet(sTable, sField, sCondition);
            ResultSet rs = queryData.getResultSet();
            if(rs.next())
                sTemp = rs.getString("ZWID").trim();
            rs.close();
            dataConn.close();
        }
        catch(SQLException sqlexception) { }
        return sTemp;
    }

    public String getYGBM(String userid)
    {
        String sTemp = "";
        try
        {
            DataConn dataConn = new DataConn();
            QueryData queryData = new QueryData(dataConn);
            String sTable = "OA_YGB";
            String sField = "BMID";
            String sCondition = "YGID=" + userid;
            queryData.setMultRecordSet(sTable, sField, sCondition);
            ResultSet rs = queryData.getResultSet();
            if(rs.next())
                sTemp = Integer.toString(rs.getInt("BMID"));
            rs.close();
            dataConn.close();
        }
        catch(SQLException sqlexception) { }
        return sTemp;
    }

    public String getZWBH(String zwid)
    {
        String sTemp = "";
        try
        {
            DataConn dataConn = new DataConn();
            QueryData queryData = new QueryData(dataConn);
            String sTable = "OA_ZWB";
            String sField = "ZWBH";
            String sCondition = "zwid=" + zwid;
            queryData.setMultRecordSet(sTable, sField, sCondition);
            ResultSet rs = queryData.getResultSet();
            if(rs.next())
                sTemp = rs.getString("ZWBH");
            rs.close();
            dataConn.close();
        }
        catch(SQLException e)
        {
            System.out.println("e=" + e.getMessage());
        }
        return sTemp;
    }

    public boolean compareDuty(String sYGBM, String sYGZW, String sYGBM_1, String sYGZW_1)
    {
        boolean temp = false;
        int i = 0;
        int len = 0;
        String sTemp = "";
        String sZWBH = "";
        int sZWBH_len = 0;
        int j = 0;
        int len_1 = 0;
        String sTemp_1 = "";
        String sZWBH_1 = "";
        int sZWBH_1_len = 0;
        IndoString indoString = new IndoString();
        len = indoString.length(sYGZW, ",", "");
        for(i = 1; i <= len; i++)
        {
            sTemp = indoString.subString(sYGZW, ",", i);
            if(!sTemp.equals("0"))
            {
                sZWBH = getZWBH(sTemp);
                sZWBH_len = sZWBH.length();
                len_1 = indoString.length(sYGZW_1, ",", "");
                for(j = 1; j <= len_1; j++)
                {
                    sTemp_1 = indoString.subString(sYGZW_1, ",", j);
                    if(!sTemp_1.equals("0"))
                    {
                        sZWBH_1 = getZWBH(sTemp_1);
                        sZWBH_1_len = sZWBH_1.length();
                        if(sZWBH_1_len >= sZWBH_len && sZWBH_1.substring(0, sZWBH_len).equals(sZWBH) && sZWBH_len != sZWBH_1.length())
                            temp = true;
                    }
                }

            }
        }

        return temp;
    }

    public static void main(String args[])
    {
        ReadRight tt = new ReadRight();
        System.out.println(tt.compareDuty("102", "60", "103", "60"));
    }
}
